package visao;

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import java.awt.GridLayout;

import javax.swing.BoxLayout;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.JTable;

import modelo.Quadrado;
import modelo.RegraDeNegocio;

import javax.swing.border.LineBorder;

import java.awt.Color;

import javax.swing.JLabel;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class Matriz extends JFrame {

	private JPanel contentPane;
	RegraDeNegocio regras = new RegraDeNegocio();
	private JLabel arrQuadrado[][] = new JLabel[4][4];
	private JLabel lbl_3_1;
	private JLabel lbl_3_2;
	private JLabel lbl_3_3;
	private JLabel lbl_2_0;
	private JLabel lbl_2_1;
	private JLabel lbl_2_2;
	private JLabel lbl_2_3;
	private JLabel lbl_1_0;
	private JLabel lbl_1_1;
	private JLabel lbl_1_2;
	private JLabel lbl_1_3;
	private JLabel lbl_0_0;
	private JLabel lbl_0_1;
	private JLabel lbl_0_2;
	private JLabel lbl_0_3;
	private JLabel lbl_3_0;

	/**
	 * Launch the application. teste
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Matriz frame = new Matriz();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Matriz() {
		
		addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				int codigo=e.getKeyCode();
				//39 -->>
				//37 <<--
				//38 cima
				//40 baixo
				if(codigo == 39){
					acaoDireita();
					JOptionPane.showMessageDialog(null,"Direita");
					
				}
				if(codigo == 37){
					acaoEsquerda();
					JOptionPane.showMessageDialog(null,"Esquerda");
				}
				if(codigo == 38){
					acaoCima();
					JOptionPane.showMessageDialog(null,"Cima");
				}
				if(codigo == 40){
					acaoBaixo();
					JOptionPane.showMessageDialog(null,"Baixo");
				}
				
			}
		});
		
		arrQuadrado[0][0] = lbl_0_0;
		arrQuadrado[1][0] = lbl_1_0;
		arrQuadrado[2][0] = lbl_2_0;
		arrQuadrado[3][0] = lbl_3_0;
		arrQuadrado[0][1] = lbl_0_1;
		arrQuadrado[1][1] = lbl_1_1;
		arrQuadrado[2][1] = lbl_2_1;
		arrQuadrado[3][1] = lbl_3_1;
		arrQuadrado[0][2] = lbl_0_2;
		arrQuadrado[1][2] = lbl_1_2;
		arrQuadrado[2][2] = lbl_2_2;
		arrQuadrado[3][2] = lbl_3_2;
		arrQuadrado[0][3] = lbl_0_3;
		arrQuadrado[1][3] = lbl_1_3;
		arrQuadrado[2][3] = lbl_2_3;
		arrQuadrado[3][3] = lbl_3_3;
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 400, 424);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		lbl_1_0 = new JLabel("");
		lbl_1_0.setBounds(22, 109, 81, 81);
		contentPane.add(lbl_1_0);
		
		lbl_1_1 = new JLabel("");
		lbl_1_1.setBounds(112, 109, 81, 81);
		contentPane.add(lbl_1_1);
		
		lbl_1_2 = new JLabel("");
		lbl_1_2.setBounds(205, 109, 81, 81);
		contentPane.add(lbl_1_2);
		
		lbl_1_3 = new JLabel("");
		lbl_1_3.setBounds(298, 109, 81, 81);
		contentPane.add(lbl_1_3);
		
		lbl_0_1 = new JLabel("");
		lbl_0_1.setBounds(112, 6, 81, 81);
		contentPane.add(lbl_0_1);
		
		lbl_0_0 = new JLabel("");
		lbl_0_0.setBounds(22, 6, 81, 81);
		contentPane.add(lbl_0_0);
		
		lbl_0_2 = new JLabel("");
		lbl_0_2.setBounds(205, 6, 81, 81);
		contentPane.add(lbl_0_2);
		
		lbl_0_3 = new JLabel("");
		lbl_0_3.setBounds(298, 6, 81, 81);
		contentPane.add(lbl_0_3);
		
		lbl_3_0 = new JLabel("");
		lbl_3_0.setBounds(22, 305, 81, 81);
		contentPane.add(lbl_3_0);
		
		lbl_3_1 = new JLabel("");
		lbl_3_1.setBounds(112, 305, 81, 81);
		contentPane.add(lbl_3_1);
		
		lbl_3_2 = new JLabel("");
		lbl_3_2.setBounds(205, 305, 81, 81);
		contentPane.add(lbl_3_2);
		
		lbl_3_3 = new JLabel("");
		lbl_3_3.setBounds(298, 305, 81, 81);
		contentPane.add(lbl_3_3);
		
		lbl_2_3 = new JLabel("");
		lbl_2_3.setBounds(298, 202, 81, 81);
		contentPane.add(lbl_2_3);
		
		lbl_2_2 = new JLabel("");
		lbl_2_2.setBounds(205, 202, 81, 81);
		contentPane.add(lbl_2_2);
		
		lbl_2_1 = new JLabel("");
		lbl_2_1.setBounds(112, 202, 81, 81);
		contentPane.add(lbl_2_1);
		
		lbl_2_0 = new JLabel("");
		lbl_2_0.setBounds(22, 202, 81, 81);
		contentPane.add(lbl_2_0);
	}
	
	public void acaoDireita(){
		
	}
	
	public void acaoEsquerda(){
		
	}

	public void acaoCima(){
	
	}

	public void acaoBaixo(){
		
		regras.Verifica2();
		
	}
	public void atualizarTela(){
		
	}
}
